#!/bin/sh

# validate just in case (see also stage1 Makefile)
if [ ! -f "$WORKDIR/syslinux/$GLOBAL_BOOTLOADER.cfg" ]; then
	echo "Warning: syslinux/*.cfg not found"
	exit 0
fi

gfxboot_datadir=/usr/share/gfxboot

if [ ! -d "$gfxboot_datadir" ]; then
	echo "** $gfxboot_datadir not found" >&2
	exit 0
fi

bootlogo="`ls $gfxboot_datadir/*/bootlogo | head -1`"	###

if [ ! -f "$bootlogo" ]; then
	echo "** bootlogo not found" >&2
	ls -alR $gfxboot_datadir
	exit 0
fi

cd "$WORKDIR/syslinux"

# unpack
cpio -iduV <"$bootlogo"

# pack
printf 'init\nlanguages\n' |
	cpio -oV >bootlogo
